package com.ruitu.mall_98_seller.mvp.model;

import com.ruitu.arad.api.BaseResult;
import com.ruitu.arad.api.PageModel;
import com.ruitu.arad.api.RxUtil;
import com.ruitu.arad.base.BaseModel;
import com.ruitu.mall_98_seller.dao.bean.AfterSale;
import com.ruitu.mall_98_seller.dao.bean.Express;
import com.ruitu.mall_98_seller.dao.bean.Order;
import com.ruitu.mall_98_seller.dao.http.APIRetrofit;

import java.util.List;

import io.reactivex.Observable;

public class OrderModel {

    // 订单列表
    public static class OrderListM extends BaseModel {
        public Observable<BaseResult<PageModel<Order>>> reqOrderList(String comId, int size, int page, String status, String type) {
            return APIRetrofit.getDefault()
                    .reqOrderList(comId, size, page, status, type)
                    .compose(RxUtil.<BaseResult<PageModel<Order>>>subIoObMain());
        }

        public Observable<BaseResult> sendMsg(String oId, String type) {
            return APIRetrofit.getDefault()
                    .sendMsg(oId, type)
                    .compose(RxUtil.<BaseResult>subIoObMain());
        }

        public Observable<BaseResult<List<Express>>> reqLogList() {
            return APIRetrofit.getDefault()
                    .expressMesList()
                    .compose(RxUtil.<BaseResult<List<Express>>>subIoObMain());
        }

        public Observable<BaseResult> reqSendGoods(String oId, String logCode, String logNum) {
            return APIRetrofit.getDefault()
                    .deliverGoods(oId, logCode, logNum)
                    .compose(RxUtil.<BaseResult>subIoObMain());
        }

        public Observable<BaseResult<AfterSale>> reqAfterSale(String oId) {
            return APIRetrofit.getDefault()
                    .afterSaleDetail(oId)
                    .compose(RxUtil.<BaseResult<AfterSale>>subIoObMain());
        }

        public Observable<BaseResult> reqRefund(String oId, String status) {
            return APIRetrofit.getDefault()
                    .refundApprove(oId, status)
                    .compose(RxUtil.<BaseResult>subIoObMain());
        }
    }

    // 订单详情
    public static class OrderDetailM extends BaseModel {
        public Observable<BaseResult<Order>> reqOrderDetail(String oId) {
            return APIRetrofit.getDefault()
                    .reqOrderDetail(oId)
                    .compose(RxUtil.<BaseResult<Order>>subIoObMain());
        }
    }
}
